// fxxk nm Physics
//update2 ans1做出来了 ans2炸了，就差一点
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long int
#define MAX_N 1000086
using namespace std;
ll T;
struct ccf{
    ll d, v, a;
};
ll n, m, L, V;
bool is_out(ccf c, int one_sensor){
    // if(c.d < one_sensor || (c.v < 0 && (c.v * (c.v * 1.0 / c.a) + 0.5 * c.a * (c.v * 1.0 / c.a) * (c.v * 1.0 / c.a) + c.d) < one_sensor )){
    if(c.d  >  one_sensor){
        
        // cout << "pass" << c.d << " " << one_sensor << " ";
        return 0;
    }
    if(sqrt(c.v * c.v + 2 * c.a * (one_sensor - c.d)) > double(V)){
        // cout << sqrt(c.v * c.v + 2 * c.a * (one_sensor - c.d)) << " ";
        return 1;
    }
    return 0;
}
void solve(){
    scanf("%lld %lld %lld %lld", &n, &m, &L, &V);
    ccf car[n+10];
    ll sencor[m+10];
    for(int i = 1; i <= n; i++){
        scanf("%lld %lld %lld", &car[i].d, &car[i].v, &car[i].a);
    }
    for(int i = 1; i <= m; i++){
        scanf("%lld", &sencor[i]);
    }
    ll ans1 = 0, ans2 = 0;
    
    int is_useful[m+10];
    int min_i = MAX_N;
    for(int i = 0; i <= m;i++){
        is_useful[i] = 0;
    }
    for(int i = 1; i <= n; i++){
        bool temp = 0;
        for(int j = 1; j <= m ; j++){
            if(is_out(car[i], sencor[j])){
                if(temp == 0)ans1++, temp=1;
                is_useful[j] += 1;
            }
        }
        // cout << endl;
    }
    for(int i = 1; i<= m; i++){
        if(is_useful[i] < ans1){
            ans2++;
        }
    }
    printf("%lld %lld\n", ans1, ans2);
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%lld", &T);
    for(int i = 1; i <= T; i++){
        solve();
    }
    return 0;
}

